using System;
using System.Collections.Generic;
using System.Text;
using Bots;
using Bots.Search;
using Lucene.Net.Documents;
using Lucene.Net.Index;
using Bots.Index;

namespace Sample
{
    public class LinkConvertor : IConvertor
    {
        private log4net.ILog logger = log4net.LogManager.GetLogger(typeof(LinkConvertor));
        #region Convertor Members

        public Lucene.Net.Documents.Document Convert(DomainObject domainObject)
        {
            Link link = domainObject as Link;
            if (link == null) return null;
            Document doc = new Document();
            doc.SetBoost(1.5f);
            doc.Add(new Field("Title", link.Title, Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("ID", link.ID.ToString(), Field.Store.YES, Field.Index.TOKENIZED));
            doc.Add(new Field("Url", link.Url, Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("CreateDate", link.CreateDateTime.ToShortDateString(), Field.Store.YES, Field.Index.UN_TOKENIZED));
            doc.Add(new Field("Description", link.Description, Field.Store.YES, Field.Index.TOKENIZED));
            logger.Info(doc.ToString());
            return doc;
        }

     
        #endregion
    }
}
